package com.spark.lola.logistics.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spark.lola.logistics.entity.ExpensesInfo;
import com.spark.lola.logistics.vo.ExpensesAnalyzeVo;
import com.spark.lola.logistics.vo.StatisticsExpensesInfoVo;
import com.spark.lola.support.mybatis.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author: Zhi-peng wang
 * @date: 2020/05/07 10:48
 * 货运支出单mapper
 **/
@Mapper
public interface ExpensesInfoMapper extends BaseMapper<ExpensesInfo> {

    IPage<ExpensesInfo> findPage(Page<ExpensesInfo> page, @Param(Constants.WRAPPER) Wrapper<ExpensesInfo> wrapper);

    int countByOrderId(long orderInfoId, int lineType);

    ExpensesInfo findByOrderId(long orderInfoId, int lineType);

    @Update("update logistics_expenses_info set total_cost=#{totalCost} where id=#{id}")
    int updateTotalCostById(BigDecimal totalCost, long id);

    List<StatisticsExpensesInfoVo> findStatistics(int status, Date startTime, Date endTime, Long empId, Long carId);

    @Select("select count(*) from logistics_expenses_info where status=#{status}")
    int countByStatus(int status);

    IPage<ExpensesAnalyzeVo> findPageAnalyze(Page<ExpensesAnalyzeVo> page, @Param(Constants.WRAPPER) Wrapper<ExpensesAnalyzeVo> wrapper);

}
